<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <#assign currentMenu="travelAllSee"/>
    <#include "../common/header.ftl">
    <script src="/js/plugins/jquery-bootstrap/jquery.bootstrap.min.js"></script>
    <script src="/js/plugins/jquery-form/jquery.form.js"></script>

    <style type="text/css">
        .modal-body {
            max-height: 750px;
            overflow-y: auto;
        }
        .modal-body img {
            width: 100%;
        }
    </style>
</head>
<body>

<div class="container " style="margin-top: 20px">
    <#include "../common/top.ftl">
    <div class="row">
        <div class="col-lg-3">
            <#include "../common/menu.ftl">
        </div>
        <div class="col-lg-9">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-head-line">大家都在看游记管理</h1>
                </div>
            </div>
            <#--高级查询--->
            <form class="form-inline" id="searchForm" action="/travelAllSee/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <div class="form-group">
                    <label>关键字:</label>
                    <input type="text" class="form-control" name="keyword" value="${(qo.keyword)!}"
                           placeholder="请输入游记标题/大攻略标题">
                </div>
                <button id="btn_query" class="btn btn-info">
                    <span class="glyphicon glyphicon-search"></span> 查询
                </button>
            </form>

            <table class="table table-striped table-hover">
                <tr>
                    <th>序号</th>
                    <th>游记标题</th>
                    <th>大攻略标题</th>
                    <th>操作</th>
                </tr>
                <#list pageInfo.list as entity>
                    <tr>
                        <td>${entity_index + 1}</td>
                        <td>${entity.travel.title}</td>
                        <td>${entity.strategy.title}</td>
                        <td>
                            <a role="button" class="btn btn-primary btn-xs contentBtn" data-json='${entity.json}'>
                                <span class="glyphicon glyphicon-sunglasses"></span> 修改内容
                            </a>
                        </td>
                    </tr>
                </#list>
            </table>
            <#include "../common/page.ftl">
        </div>
    </div>
</div>

<#-- 设置大家都在看游记 -->
<div id="allseeModal" class="modal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">设置大家都在看</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/travelAllSee/saveOrUpdate.do" method="post"
                      enctype="multipart/form-data" id="changeForm">
                    <input type="hidden" name="travel.id"/>
                    <input type="hidden" name="id"/>
                    <div class="form-group" >
                        <label class="col-lg-4 control-label">标题：</label>
                        <div class="col-lg-6">
                            <input type="text" class="form-control" id="title" readonly/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-4 control-label">大攻略类型：</label>
                        <div class="col-lg-6">
                            <select class="form-control" name="strategy.id">
                                <#list strategies as st>
                                    <option value="${st.id}">${st.title}</option>
                                </#list>
                            </select>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary editBtn">保存</button>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    $(function () {
        //弹出添加大家都在看的模态框
        $(".contentBtn").click(function () {
            var json = $(this).data("json");
            //回显数据: 游记id/游记标题
            $("#changeForm input[name='travel.id']").val(json.travelId);
            $("#changeForm select[name='strategy.id']").val(json.strategyId);
            $("#changeForm input[name='id']").val(json.id);
            $("#title").val(json.travelTitle);
            //显示模态框
            $("#allseeModal").modal("show");
        });
        //提交表单
        $(".editBtn").click(function () {
            $("#changeForm").ajaxSubmit(function (data) {
                if (data.success){
                    window.location.href = "/travelAllSee/list.do";
                } else{
                    alert(data.msg);
                    window.location.reload();
                }
            });
        });
    });
</script>
</body>
</html>